import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

/**
 * Created by 焕滨 on 2016/3/12.
 */

public class Solution {
    public int getValue(int[] gifts, int n) {
        Map<Integer,Integer> giftMap = new HashMap<Integer,Integer>();
        for(int gift:gifts){
            int times;
            if(giftMap.containsKey(gift)){
                times = giftMap.get(gift) + 1;
            }
            else {
                times = 1;
            }
            if(times > n/2){
                return gift;
            }else {
                giftMap.put(gift,times);
            }
        }
        return 0;
    }

    public static void main(String[] args){
        Solution s = new Solution();
//        System.out.println(s.getGray(2));
    }
}
